package at.fhooe.mc.master.clc.server.dataaccess.dao;

import java.lang.reflect.Type;
import java.util.List;
import java.util.Map;

import at.fhooe.mc.master.clc.server.domain.ITestable;

/**
 * This is a general DAO for all ITestable classes. 
 * If no specific handling for the test class is needed in the DAO,
 * this dao can be used for creating the metrics.
 * 
 * @author Daniel Karzel
 *
 */
public interface ITestableDao
{
	/**
	 * Saves the given entity
	 * @param testable
	 * @return
	 */
	public int save(ITestable testable);
	
	/**
	 * Saves all the given entities.
	 * @param testables
	 * @return
	 */
	public int save(List<ITestable> testables);
	
	/**
	 * Loads all entries of the given type.
	 * @param type type to be loaded
	 * @return 
	 */
	public List<? extends ITestable> loadAll(Class<? extends ITestable> type);
	
	/**
	 * Loads data filtered. Unfortunately we cannot just pass an arbitrary number of
	 * filters (field-value pairs), because some frameworks filter by method call, 
	 * thus the specific variable is needed once one filters.
	 * <br>
	 * Through method it is possible to filter for 4 different criteria (fields). <br>
	 * Note: If a field parameter is left null, the filter won't be used. Note that this works only in 
	 * ascending order (one cannot leave field1 null and assume that the other fields will be filtered - 
	 * if field1 is null nothing will be filtered).
	 * 
	 * @param type
	 * @param field1
	 * @param filter1
	 * @param field2
	 * @param filter2
	 * @param field3
	 * @param filter3
	 * @param field4
	 * @param filter4
	 * @return
	 */
	public List<? extends ITestable> loadFilteredEquals(Class<? extends ITestable> type, 
			String field1, Object filter1, 
			String field2, Object filter2, 
			String field3, Object filter3, 
			String field4, Object filter4);
	
	/**
	 * Loads one specific element by id.
	 * @param type
	 * @param id
	 * @return
	 */
	public ITestable loadSpecific(Class<? extends ITestable> type, long id);
	
	/**
	 * Loads one specific element by id.
	 * @param type
	 * @param id
	 * @return
	 */
	public ITestable loadSpecific(Class<? extends ITestable> type, String id);
	
	/**
	 * Deletes a given entity.
	 * @param testable
	 * @param specificClass TODO
	 * @return
	 */
	public int delete(ITestable testable, Class<? extends ITestable> specificClass);
	
	/**
	 * Delete all entries of the given list
	 * @param specificClass
	 * @return
	 */
	public int deleteAll(List<ITestable> toBeDeleted);
	
}
